package com.chenjiagou.flight.repository;

import com.chenjiagou.flight.model.Airport;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface AirportRepository extends JpaRepository<Airport, String> {
    // 查询所有机场名称并按代码升序排序
    @Query("SELECT DISTINCT a.name FROM Airport a ORDER BY a.code ASC")
    List<String> findDistinctNamesOrderedByCode();
    
    // 新增：根据机场代码查找机场
    Optional<Airport> findByCode(String code);
}